Field of the Invention
This invention relates generally to a system and method for supporting coherent data access on a multicore controller and, more particularly, to a system and method that provides two buffers, an indicator, and a synchronization protocol that allows one buffer to be read from while the other buffer is written, and where read and write responsibilities switch between the two buffers.
Discussion of the Related Art
Modern vehicles employ various embedded electronic controllers that improve the performance, comfort, safety, etc. of the vehicle. Such controllers include engine controllers, suspension controllers, steering controllers, power train controllers, climate control controllers, infotainment system controllers, chassis system controllers, etc. These controllers typically require special purpose software and algorithms to perform their control functions.
The current trend for vehicle electronic controllers is to provide multiple software applications for different functions operating on a common controller. For example, adaptive cruise control (ACC) systems, lane centering systems, stability control systems, etc. are all known in the art and all of which automatically control vehicle steering and/or braking in some fashion. These systems often times employ the same sensor inputs and other variables, sometimes referred to as global variables, that when stored in memory can be used by more than one software application. For example, the ACC system may read the sensor data and write the sensor data into the controller memory during its operation on the processor, and the lane centering system and other software applications may read that data when they are running on the processor. Thus, it makes sense in many cases such as these to run multiple software applications on the same processor.
Providing multiple related software applications running on a common controller has obvious advantages for reducing system hardware and cost. However, operating different software applications on the same processor increases the complexity of the controller because of the scheduling required to run the different software applications and prevent the software applications from interfering with each other. Such mixed use applications operating on a single processor is further increased in complexity when a vehicle OEM provides additional software on a controller already having software provided by a supplier.
In multiple related software applications and/or multicore computer environments, if one or more software applications of execution attempt concurrent operations on the same critical resources a problem may arise. For example, when the software applications attempt simultaneous access to a shared data record that needs to be updated atomically, it may cause a race condition that in turn may cause a program failure. Synchronization procedures are used to prevent these conditions from occurring. Known synchronization methods use locking mechanisms or lock-free mechanisms to provide software application access to critical resources to prevent race conditions, and similar problems, from occurring.
Locking mechanisms use a method that permits only one software application at a time to acquire a lock and subsequently conduct processing operations on a critical resource. When a software application holds a lock to a critical resource, other software applications attempting to access the critical resource will be paused and placed in a waiting queue. Once the lock is released, the next software application at the head of the waiting queue will be given the lock and allowed to proceed with processing operations. While the locking synchronization approach discussed above prevents race conditions, the necessary pausing of software applications slows down processing. Additionally, if a software application holding the lock fails to complete processing, the program may become unresponsive.
Another known method, commonly referred to as lock-free synchronization, guarantees that only one software application can update a critical resource. If a second software application attempts to update while a first software application is updating critical resource, the second software application's attempt will fail. If the second software application fails it will restart the update attempt after the first software application completes updating to the critical resource. While lock-free synchronization can produce greater execution performance compared to locking synchronization, it is not always possible to implement for some critical resources. Other known approaches, such as those that are wait-free, require excessive memory and require a minimum of three copies of data sets.